package marvin.client;

import java.util.Scanner;

import marvin.client.core.SubscriptionClient;
import marvin.client.ui.JF_Main;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String mode = System.getProperty("marvin.ui");
		
		if("graphical".equals(mode)){
			JF_Main main = new JF_Main();
			main.setVisible(true);
		} else {
			SubscriptionClient client;
			String port="", clientName="";
			String server = System.getProperty("marvin.host");;
			
			Scanner sc = new Scanner(System.in);
			System.out.println("Server name ("+server+"): ");
			String userServer = sc.nextLine();
			if(userServer != null && !userServer.isEmpty())
				server = userServer;
			
			System.out.println("Server port: ");
			port = sc.nextLine();
			
			System.out.println("Client name: ");
			clientName = sc.nextLine();
			
			System.out.print("Try to connect to "+server+":"+port+" as "+clientName+" ... ");
			client = new SubscriptionClient(Integer.parseInt(port), server);
			client.sendId(clientName);
			System.out.println(" done.");
		}
	}

}
